import { _decorator, Collider2D, Component, instantiate, IPhysics2DContact, Node, Prefab } from 'cc';
import { BulletController } from './BulletController';
import { BundleManager, Bundles } from '../AshFramework/Managers/BundleManager';
import { GameManager } from './GameManager';
import { Explosion_Grenade } from './Explosion_Grenade';
import { Constant } from '../AshFramework/Datas/Constant';
import { EnemyController } from './EnemyController';
const { ccclass, property } = _decorator;

@ccclass('BulletController_SLD')
export class BulletController_SLD extends BulletController {
    removeSelf() {
        this.IsRemove = true;
        const worldPos = this.node.getWorldPosition().clone();
        const angle = this.node.angle;
        BundleManager.LoadPrefab(Bundles.Prefabs, "爆炸效果_手榴弹").then((prefab: Prefab) => {
            const hit = instantiate(prefab);
            hit.parent = GameManager.Instance.Canvas;
            hit.getComponent(Explosion_Grenade).show(worldPos, angle, this.Harm, this.ArmorPenetration);
        })
        this.scheduleOnce(() => { this.node.destroy(); })
    }

    // onBeginContact(selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
    //     // 只在两个碰撞体开始接触时被调用一次
    //     if (this.IsRemove) return;
    //     this.removeSelf();
    // }
}


